<!doctype html>
<html>

	<head>
		<meta charset="UTF-8" />
		<title>升级为金钻</title>
		<link rel="stylesheet" href="../css/common.css" />
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" type="text/css" href="../css/mui.css" />
		<script src="../js/mui.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			mui.init();
		</script>
		<script type="text/javascript" src="../js/common.js"></script>
		<style>

		</style>
	</head>

	<body style="background: #FFFFFF;">
		<div class="mui-content" style="background: #FFFFFF;">
			<form class="mui-input-group">
				<div class="mui-input-row">
					<label>升级金额</label>
					<input type="text" class="mui-input reg_phone" value="1000元" readOnly="true">
				</div>
				<div class="mui-input-row">
					<label>支付方式</label>
						<select id="paymentType">
					 		<option value="none">请选择支付方式</option>
					 		<option value="Balance">余额支付</option>
						</select>
					<span class="mui-icon mui-icon-arrowdown" style="position: absolute;right: 0.1rem;top: 20%;"></span>
				</div>
				<div class="mui-input-row">
					<label>支付密码</label>
					<input type="password" class="mui-input-clear" placeholder="请输入百商汇支付密码" id="paypassword">
				</div>
			</form>
			<div class="mui-content-padded">
				<button id='leave_up' class="mui-btn mui-btn-block mui-btn-danger">确认</button>
			</div>
			<div class="mui-content-padded agreement">
				<p style="text-align: center;">确认表示同意<a>《用户协议》</a></p>
			</div>
		</div>
	</body>

</html>
<script>
	document.getElementById("leave_up").addEventListener("tap", function() {
		var paymentType = document.getElementById("paymentType").value
		var paypassword = document.getElementById("paypassword").value
		mui.ajax('/api/v1/upgrade/member/balance', {
			data: {
				paramStr: "{userName:" + sessionStorage.userName + ",token:" + sessionStorage.token + ",paypassword:" + paypassword + ",paymentType:" + paymentType + ",level:gold}"
			},
			dataType: 'json',
			type: 'post',
			success: function(data) {

				if (data.code == 200) {
					sessionStorage.level = "gold";
					
					function jump(){
					mui.openWindow({
						url: "homepage.html",
					});
					}
					mui.alert(data.message,jump);
					return
				}

				mui.toast(data.message);
			},
			error: function(xhr, type, errorThrown) {
				//异常处理；
				mui.toast("未知错误")
			}

		});
	});
</script>